<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            登录
        </div>
        <div class="header-r aui-pull-right">
        </div>
    </header>
    <div style="height:4rem;"></div>


    <div class="login">
        <ul>
            <li>
                <label><i class="aui-iconfont aui-icon-mobile"></i></label>
                <input type="text" placeholder="输入手机号" id="phone">
            </li>
            <li>
                <label><i class="aui-iconfont aui-icon-lock"></i></label>
                <input type="password" placeholder="输入密码" id="password">
            </li>
        </ul>

        <div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm" onclick="login();">登录</div>

        <div class="login-d">
            <div>忘记密码</div>
            <div onclick="register();">快速注册</div>
        </div>
    </div>





</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">

    apiready = function(){

    }


    // 登录
    function login(){

        var phone = $api.byId('phone').value;
        var password = $api.byId('password').value;

        api.ajax({
            url: 'http://fxapp.1024wl.cn/a/member/Login/index',
            method: 'post',
            data: {
                values: {
                    username: phone,
                    password: password,
                },
            },
            headers: {
                TOKEN: token,
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );
                api.toast({
                    msg: ret.message,
                    duration: 2000,
                    location: 'bottom',
                    global: 'true',
                });
                $api.setStorage('userid', ret.result.uid);
                $api.setStorage('authtoken', ret.result.token);
                $api.setStorage('phone', ret.result.data.tel);
                api.sendEvent({
                    name: 'reload'
                });
                api.closeWin();
            } else {
                api.toast({
                    msg: err.body.message,
                    duration: 2000,
                    location: 'bottom'
                });
                return false;
            }
        });

    }

    // 打开注册页
    function register(){
        api.openWin({
            name: 'register',
            url: './register.html',
            pageParam: {
                name: 'test'
            }
        });
    }

    // 注册成功后 返回登录页 显示手机号
    function showPhoneNumber(){
        var phone = $api.getStorage('phone');
        document.getElementById('phone').value = phone;
    }

    function coupondetails(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'coupondetails',
            url: './coupon-details.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    };
    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>
